/**
 ******************************************************************************
 * @file    main.h
 * @author  Hsiang Hsu
 * @brief   Header for main.c module
 ******************************************************************************
 * @attention
 *
 * CONFIDENTIAL AND PROPRIETARY
 * Unpublished Copyright (c) 2024 Hsiang Hsu, All Rights Reserved.
 *
 ******************************************************************************
 */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MAIN_H
#define __MAIN_H

/* Includes ------------------------------------------------------------------*/

#if defined(USE_FULL_ASSERT)
#include "stm32_assert.h"
#endif /* USE_FULL_ASSERT */

// LL library
#include "stm32f1xx_ll_adc.h"
#include "stm32f1xx_ll_bus.h"
#include "stm32f1xx_ll_cortex.h"
#include "stm32f1xx_ll_crc.h"
#include "stm32f1xx_ll_dac.h"
#include "stm32f1xx_ll_dma.h"
#include "stm32f1xx_ll_exti.h"
#include "stm32f1xx_ll_gpio.h"
#include "stm32f1xx_ll_i2c.h"
#include "stm32f1xx_ll_iwdg.h"
#include "stm32f1xx_ll_pwr.h"
#include "stm32f1xx_ll_rcc.h"
#include "stm32f1xx_ll_rtc.h"
#include "stm32f1xx_ll_spi.h"
#include "stm32f1xx_ll_system.h"
#include "stm32f1xx_ll_tim.h"
#include "stm32f1xx_ll_usart.h"
#include "stm32f1xx_ll_utils.h"
#include "stm32f1xx_ll_wwdg.h"

//
#include "bsp_init.h"
#include "tusb.h"

/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/

#if defined(__GNUC__)
#define __maybe_unused __attribute__((unused))
#else
#define __maybe_unused
#endif
#define ASSERT_EXPR(expr) __maybe_unused typedef char assert_type[expr ? 1 : -1]
#define USART_BUF_LEN 4096 // 定义缓存2048字节
#define VOFA_DATA_LEN 40 // 定义Vofa数据长度，sizeof(ICM_DATA_t) + sizeof(BMP_DATA_t) + 4
#define LED1_Toggle LL_GPIO_TogglePin(GPIOB, LL_GPIO_PIN_0)
/* Exported types ------------------------------------------------------------*/
// 浮点->无符号 转换
union FL2UCH
{
    float f;
    unsigned char c[4];
};

// 数据缓存结构体
typedef struct
{
    unsigned char buf[USART_BUF_LEN];
    __IO unsigned char len;
} SDATA;

// 串口设备数据结构
typedef struct
{
    unsigned char rxbuf[USART_BUF_LEN];
    unsigned char txbuf[USART_BUF_LEN]; // 发送数据缓冲，把待发送的数据写在这里
    unsigned short rxlen;
    unsigned short txlen; // 控制数据发送长度，注意如果 txlen < txbuf, 则只发送部分数据 txlen <= USART_BUF_LEN
    unsigned char rxflag;
    unsigned char txflag;
} SUART;
/* Exported functions ------------------------------------------------------- */
extern SUART suart1;
extern SDATA sdat;
#endif

/* end------------------------------------------------------------------------*/
